﻿<%@ WebHandler Language="C#" Class="wxMiniProgramLogin" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using System.Web.Configuration;   
using Newtonsoft.Json.Linq;
using System.IO;
using System.Net;


public class wxMiniProgramLogin : IHttpHandler {
      
        public void ProcessRequest (HttpContext context) 
        {
        context.Response.ContentType = "text/plain";

        var xxx=HttpContext.Current.Request.Form["paramJson"];
        JObject jo = (JObject)JsonConvert.DeserializeObject(xxx);
        var openid=jo["onlyId"].ToString();
        var nickName=jo["nickName"].ToString();
              var birthday=jo["birthday"].ToString();
              var sex=jo["relationship"].ToString();


  

        using (Entities db = new Entities())
        {
            var wxuser = db.User.FirstOrDefault(p => p.UOpenID == openid);
              wxuser.UNickName=nickName;
              wxuser.Utype=birthday;
               wxuser.USex=sex;


              wxuser.isMember=1;
              db.SaveChanges();

        };

      
          var  code = 1;
          var  msg = "zhuc";
          var  time = DateTime.Now;
       
        context.Response.Write(JsonConvert.SerializeObject(new {code,msg,time}));

        HttpContext.Current.Response.End();
        //context.Response.Write("Hello World");


       }


    public bool IsReusable {
        get {
            return false;
        }
    }

}